﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>条码打印</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
@if (ViewData["operate"].ToString().Contains("pintbar"))
{
        <a title="条码打印" href="javascript:;" lay-event="done"><i class="layui-icon">&#xe66d;</i></a>
}
@if (ViewData["operate"].ToString().Contains("replan"))
{
        <a title="计划重启" href="javascript:;" lay-event="reset"><i class="layui-icon">&#xe667;</i></a>
}
        <a title="占用明细" href="javascript:;" lay-event="zymx"><i class="layui-icon">&#xe670;</i></a>
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="ptCode" placeholder="派工单号" autocomplete="off" class="layui-input" id="ptCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>
              
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="proCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="spec" placeholder="规格货号" autocomplete="off" class="layui-input" id="spec">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <select id="process" name="process" class="process">
                                    <option value="">生产工序</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <select id="status" name="status" >
                                    <option value="">计划状态</option>
                                    <option value="pro-doing">进行中</option>
                                    <option value="do-finish">生产完成</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>

                        </form>
                    </div>

                    <div class="layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>

    function loadData() {
        var ptype = $("#process").val();
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
               { field: 'ptCode', title: '派工单号', width: 120 }
             , { field: 'ptTypeName', title: '计划类型', width: 100 }
             , { field: 'processName', title: '生产工序', width: 100 }
             , { field: 'proName', title: '存货名称', width: 140 }
             , { field: 'spec', title: '规格', width: 120 }
             , { field: 'barCount', title: '可用卷数', width: 100 }
             , { field: 'c_changdu', title: '长度合计', width: 120 }
             , { field: 'thickness', title: '厚度', width: 120 }
             , { field: 'c_hjcontents', title: '长度', width: 120 }
             , { field: 'statusName', title: '计划单状态', width: 100 }
             , { field: 'createtime', title: '创建时间', width: 150 }
             , { field: 'memo', title: '备注说明', width: 150 }
             , { field: 'right', title: '操作', toolbar: '#barDemo', width: 100, fixed: 'right' }
            ]], done: function (res, curr, count) {
                if (ptype != "cm") {
                    $("[data-field='c_changdu']").css('display', 'none');
                    $("[data-field='c_hjcontents']").css('display', 'none');
                    $("[data-field='spec']").css('display', '');
                    $("[data-field='barCount']").css('display', '');
                } else {
                    $("[data-field='c_changdu']").css('display', '');
                    $("[data-field='c_hjcontents']").css('display', '');
                    $("[data-field='spec']").css('display', 'none');
                    $("[data-field='barCount']").css('display', 'none');
                }
                $("[data-field='id']").css('display', 'none');//隐藏列
                $.each(res['data'], function (i, j) {
                    if (j['status'] == "do-finish") {
                        TableRowColor('layui-table-main', i, '#FFD700');
                    } 
                });
            }
            , url: "../Plan/getDataList?dataType=pgd&condition=" + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [20, 30, 50]
            , limit: 30 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event === 'done') {
                    if (data['status'] == "FNS") {
                        layer.msg("该计划已完成"); return;
                    }
                    var win = data.ptType + "-bar";
                    SSO(win, JSON.stringify(data));
                   
                } else if (obj.event == 'zymx') {
                    var info = "存货编码：" + data.proCode + "；  存货名称：" + data.proName + "；  规格型号：" + data.spec;
                    var url = "../Plan/PlanZhanYong?plCode=" + data.plCode+"&msg="+info;
                    OpenPage("生产工序", url);
                } else if (obj.event === 'reset') {
                    if (data['status'] != "do-finish") {
                        layer.msg("该计划无需重启"); return;
                    }
                    layer.confirm('确认要重新开启该计划？', function (index) {
                        $.ajax({
                            url: "../Plan/OpenPlanStatus",
                            data: { ptCode: data.ptCode },
                            dataType: "json",
                            async: false,
                            type: "POST",
                            success: function (rsl) {
                                if (rsl.Result) {
                                    loadData();
                                } else {
                                    layer.msg(rsl.Message);
                                }
                                layer.close(index);
                            }
                        });
                      
                    });
                }
            });

        });
    }
    $(function () {
        loadGxInfo();
        loadData();
    })
    /**
    验证版辊是否在库
    **/
    function checkBanGun(datas) {
        $.ajax({
            url: "../Plan/CheckPlanBanGun",
            data: { ptCode: datas.ptCode },
            dataType: "json",
            async: false,
            type: "POST",
            success: function (rsl) {
                if (rsl.Result) {
                    var win = datas .ptType+ "-bar";
                    SSO(win, JSON.stringify(datas));
                } else {
                    layer.msg(rsl.Message);
                }
                layer.close(index);
            }
        });
    }
    /**
    生产工序
    **/
    function loadGxInfo() {
        $.ajax({
            url: "../Basis/GetCommonData",
            data: { type: "proGx" },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                if (data.Result) {
                    var datas = data.Data;
                    for (var i = 0 ; i < datas.length; i++) {
                        if (datas[i].specFile != "0") {
                            $(".process").append("<option value=\"" + datas[i].cCode + "\" >" + datas[i].cName + "</option>");
                        }

                    }
                }

            }
        });
    }
</script>